<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>个人资料--海上事故管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
	<meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8" />
    <link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="plugins/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="css/user.css" media="all" />
</head>
<body class="childrenBody">
<form class="layui-form">
    <div class="user_left">
        <div class="layui-form-item">
            <label class="layui-form-label">用户ID</label>
            <div class="layui-input-block">
                <input type="text" value="${user.userId}" name="userId" disabled class="layui-input layui-disabled">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-block">
                <input type="text" value="${user.username}" name="username" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">权限</label>
            <div class="layui-input-block">
                <input type="text" value="管理员" disabled class="layui-input layui-disabled" id="authority" name="authority">
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">所处地区</label>
            <div class="layui-input-block">
                <select name="province" lay-filter="province" name="province" id="province">
                    <option value="">请选择省</option>
                </select>
            </div>
            <div class="layui-input-block">
                <select name="city" lay-filter="city" id="city" name="city">
                    <option value="">请选择市</option>
                </select>
            </div>
            <div class="layui-input-block">
                <select name="area" lay-filter="area" id="area" name="area">
                    <option value="">请选择县/区</option>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">邮箱</label>
            <div class="layui-input-block">
                <input type="text" name="email" value="${user.email}" placeholder="请输入邮箱" lay-verify="required|email" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" name="other" class="layui-textarea">
                ${user.other}
                </textarea>
            </div>
        </div>
    </div>
    <div class="user_right">
        <img id="icon" src="${user.iconUrl}" width="170px" height="170px" onclick="iconEdit()"></img>
    </div>
    <div class="layui-form-item" style="margin-left: 5%;">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="changeUser">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<div id="uploadModal" class="modal fade" tabindex="-1" role="dialog">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
				<h4 class="modal-title">上传头像</h4>
			</div>
			<div class="modal-body">
				<input type="file" id="file" name="file"></input>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
				<button type="button" class="btn btn-default" onclick="subIcon()">Save</button>
			</div>
		</div>
	</div>
</div>
<script src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="plugins/layui/layui.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="json/address.js"></script>
<script type="text/javascript" src="js/user.js"></script>
<script>
function iconEdit(){
	$("#uploadModal").modal('show');
};
function subIcon(){
	var formData = new FormData();  
	formData.append('file',$("#file")[0].files[0]);
	debugger;
	$.ajax({
		type: "POST",
        enctype: 'multipart/form-data',
		url : "user/changeIcon",
		data :  formData,
		contentType: false ,
		processData: false,  
		success : function(data){
			$("#uploadModal").modal('hide');
			/* alert({
				title:"家庭头像修改成功！各处图标待网站刷新后刷新。",
				showConfirmButton: false 
			}) */
			window.setTimeout("window.location.href='userPage'",1500);
		},
		error : function(){
			alert("系统错误请联系管理员！");
		}
	})
};
</script>
</body>
</html>